package ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fy.fyzf.R;

import java.util.List;

public class CheckBoxAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context mContext;
    public CheckBoxAdapter(Context context) {
        super(R.layout.item_checkbos);
        mContext = context;
    }

    private int selectPos = 0;
    public void setSelect(int i){
        selectPos = i;
        notifyDataSetChanged();
    }

    public int getSelectPos() {
        return selectPos;
    }

    public void setSelectPos(int selectPos) {
        this.selectPos = selectPos;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        RadioButton radioButton = helper.getView(R.id.checkbox);
        EditText editText = helper.getView(R.id.et_remark);

        radioButton.setText(item);
        if (helper.getAdapterPosition() == getItemCount() - 1 ) {
            editText.setVisibility(View.VISIBLE);
        }else {
            editText.setVisibility(View.GONE);
        }
        if (selectPos == helper.getAdapterPosition()) {
            radioButton.setChecked(true);
        } else {
            radioButton.setChecked(false);
        }
    }
}
